library("doRedis")

options('redis:num'=TRUE)

func <- function(x) {
  a <- 4*sum((runif(1000000)^2 + runif(1000000)^2)<1)/10000000
  return(c(a))
}

registerDoRedis("jobs")
startLocalWorkers(n=2, queue="jobs")
foreach(icount(10), .combine=sum, 
        .multicombine=TRUE, .inorder=FALSE) %dopar% func(x)
removeQueue("jobs")
